﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using Slwy.Application.Interfaces;
using Slwy.Core.Entities;
using Slwy.FrameCore.Dependency;
using Slwy.MySql.Contracts;
using Slwy.Utility.Extensions;

namespace Slwy.Application.Services
{
    public class CarrierService : ICarrierService
    {
        private readonly Core.DomainService.IService.ICarrierService _carrierService;

        public CarrierService(Core.DomainService.IService.ICarrierService carrierService)
        {
            ServiceLocator.Instance.GetServiceEx<ICarrierService>();
            _carrierService = carrierService;
        }

        public PressionResultOutDto AddCarrier(IList<CarrierInfo> entities)
        {
            var outDto = new PressionResultOutDto();
            Stopwatch sw = new Stopwatch();
            sw.Start();
            this._carrierService.AddCarrierByEF(entities);
            this._carrierService.UpdateCarrierByEF();
            sw.Stop();
            outDto.EFTime = sw.Elapsed.TotalMilliseconds;


            sw = new Stopwatch();
            sw.Start();
            this._carrierService.AddCarrierBySqlSugar(entities);
            this._carrierService.UpdateCarrierBySqlSugar();
            sw.Stop();
            outDto.SqlSugarTime = sw.Elapsed.TotalMilliseconds;

            return outDto;
        }
    }
}
